package com.bjbn.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * OpenAPI配置类 - Swagger文档配置
 */
@Configuration
public class OpenApiConfig {

    @Value("${server.port:33018}")
    private String serverPort;

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("数据迁移API")
                        .description("数据迁移API是一个基于Spring Boot的应用程序，用于将MySQL数据库中的bridge_info表数据同步到Elasticsearch。该API提供了完整的数据迁移功能和搜索查询接口。")
                        .version("1.0.0")
                        .contact(new Contact()
                                .name("开发团队")
                                .email("dev@bjbn.com")
                                .url("https://www.bjbn.com"))
                        .license(new License()
                                .name("MIT License")
                                .url("https://opensource.org/licenses/MIT")))
                .servers(Arrays.asList(
                        new Server()
                                .url("http://localhost:" + serverPort)
                                .description("本地开发环境"),
                        new Server()
                                .url("http://10.120.78.214:" + serverPort)
                                .description("生产环境")
                ));
    }
}
